/*
 *
 *  Copyright (C) 2012-2024
 *  All rights reserved, Designed By 杭州连线客信息技术有限公司
 *  注意：
 *  本软件为杭州连线客信息技术有限公司开发研制，未经购买不得使用
 *  购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 *  一经发现盗用、分享等行为，将追究法律责任，后果自负
 *
 */

package com.lxk.oms.postorder.flow.refund;

import com.lxk.oms.postorder.domain.bo.OmsPostOrderBo;
import com.lxk.oms.postorder.domain.vo.OmsPostOrderVo;
import com.lxk.oms.postorder.service.IOmsPostOrderService;
import com.lxk.service.idgenerator.GeneratorType;
import com.lxk.service.idgenerator.IdGeneratorServiceApi;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.log.LFLog;
import com.yomahub.liteflow.log.LFLoggerManager;
import lombok.AllArgsConstructor;

import static com.lxk.oms.postorder.flow.refund.FlowRefundPostOrderNodeConst.GEN_NO_REFUND_POST_ORDER_NODE;

/**
 * 生成退款编号并且更新
 *
 * @author heyi
 * 2024/9/29
 */
@AllArgsConstructor
@LiteflowComponent(value = GEN_NO_REFUND_POST_ORDER_NODE)
public class PostOrderGenNoRefundNode extends NodeComponent {
    private final LFLog log = LFLoggerManager.getLogger(FlowExecutor.class);
    private final IOmsPostOrderService omsPostOrderService;
    private final IdGeneratorServiceApi generatorServiceApi;

    @Override
    public void process() throws Exception {
        PostOrderRefundContext contextBean = this.getContextBean(PostOrderRefundContext.class);
        OmsPostOrderVo postOrder = contextBean.getPostOrder();
        OmsPostOrderBo update = new OmsPostOrderBo();
        update.setId(postOrder.getId());
        String generatorSn = generatorServiceApi.generatorSn(GeneratorType.WX_OUT_POST_ORDER);
        postOrder.setOutRefundNo(generatorSn);
        update.setOutRefundNo(generatorSn);
        omsPostOrderService.updateByBo(update);

    }
}
